package com.sinosoft.demo2;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.sinosoft.domain.CustomerListVO;
import com.sinosoft.domain.Person;
import org.w3c.dom.ls.LSInput;

import java.math.BigDecimal;
import java.sql.SQLOutput;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

/**
 * @Author: WangShengJie
 * @Date: 2024/9/5
 */
public class ListDemo {
    public static void main(String[] args) {
        String tetJson = "{\n" +
                "    \"stateCode\": 0,\n" +
                "    \"data\": {\n" +
                "        \"rows\": [\n" +
                "            {\n" +
                "                \"name\": \"程波\",\n" +
                "                \"mobile_phone\": \"15031990793\",\n" +
                "                \"pinyin_name\": \"chengbo\",\n" +
                "                \"wechat_nick\": \"\",\n" +
                "                \"one_id\":\"\",\n" +
                "                \"customer_class\":\"\",\n" +
                "                \"star_customer\":\"\",\n" +
                "                \"pol_num\":\"\",\n" +
                "                \"prem\":\"\",\n" +
                "                \"image_url\":\"\"\n" +
                "            },\n" +
                "            {\n" +
                "                \"name\": \"测试\",\n" +
                "                \"mobile_phone\": \"13814201670\",\n" +
                "                \"pinyin_name\": \"ceshi\",\n" +
                "                \"wechat_nick\": null,\n" +
                "                \"one_id\":\"\",\n" +
                "                \"customer_class\":\"\",\n" +
                "                \"star_customer\":\"\",\n" +
                "                \"pol_num\":\"\",\n" +
                "                \"prem\":\"\",\n" +
                "                \"image_url\":\"\"\n" +
                "            },\n" +
                "            {\n" +
                "                \"name\": \"陈晓蕾2\",\n" +
                "                \"mobile_phone\": \"13880676621\",\n" +
                "                \"pinyin_name\": \"chenxiaolei\",\n" +
                "                \"wechat_nick\": \"\",\n" +
                "                \"one_id\":\"\",\n" +
                "                \"customer_class\":\"\",\n" +
                "                \"star_customer\":\"\",\n" +
                "                \"pol_num\":\"\",\n" +
                "                \"prem\":\"\",\n" +
                "                \"image_url\":\"\"\n" +
                "             }\n" +
                "        ]\n" +
                "    },\n" +
                "    \"message\": null\n" +
                "}";
//        Person p1 = new Person();
//        Person p2 = new Person(new BigDecimal("205"), true, "777");
//        List list = new ArrayList();
//        list.add(p1);
//        list.add(p2);
//        System.out.println(list);
//        String s = JSON.toJSONString(list);
//        System.out.println(s);
//        System.out.println("******");
//        List list1 = JSON.parseObject(s, List.class);
//        System.out.println(list1.toString());
        JSONObject jsonObject = JSON.parseObject(tetJson);
//        System.out.println(jsonObject);
        JSONObject data = jsonObject.getJSONObject("data");
        JSONArray array = data.getJSONArray("rows");
        System.out.println(array);
        System.out.println(array.size());
        List list = new ArrayList();
        for (Object o : array) {
            CustomerListVO vo = JSON.parseObject(String.valueOf(o), CustomerListVO.class);
            list.add(vo);
        }
        System.out.println(list);

    }
}
